package com.ft.adbix.utils.data;

import android.content.Context;
import android.content.SharedPreferences;

import com.ft.adbix.oaid.OAIDManager;

public class SPManager {
    private static final String SP_NAME = "com.ft.adbix";

    public SPManager() {
    }

    private static final class InstanceHolder {
        static final SPManager instance = new SPManager();
    }

    public static SPManager getInstance() {

        return InstanceHolder.instance;
    }

    public void putString(String key, String value) {
        try {
            this.getSP().edit().putString(key, value).apply();
        } catch (Exception var5) {
            var5.printStackTrace();
        }
    }

    public void putInt(String key, int value) {
        try {
            this.getSP().edit().putInt(key, value).apply();
        } catch (Exception var5) {
            var5.printStackTrace();
        }
    }

    public void putLong(String key, long value) {
        try {
            this.getSP().edit().putLong(key, value).apply();
        } catch (Exception var5) {
            var5.printStackTrace();
        }
    }

    public String getString(String key) {
        try {
            return this.getSP().getString(key, null);
        } catch (Exception var4) {
            var4.printStackTrace();
            return null;
        }
    }

    public int getInt(String key, int defaultValue) {
        try {
            return this.getSP().getInt(key, defaultValue);
        } catch (Exception var4) {
            var4.printStackTrace();
            return 0;
        }
    }

    public long getLong(String key, long defaultValue) {
        try {
            return this.getSP().getLong(key, defaultValue);
        } catch (Exception var4) {
            var4.printStackTrace();
            return 0;
        }
    }

    private SharedPreferences getSP() {
        return OAIDManager.getInstance().getContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    }
}
